	<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>制造商品牌管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				rules:{          
					type:{required:true},
					name:{required:true,stringCheck:true,remote: "${ctx}/sys/vender/checkSameName?oldName=" + encodeURIComponent("${vender.name}")}, 
					remarks:{remarkCheck:true}
	            },
				messages:{
					type:{required:"请输入品牌分类"},
					name:{required:"请输入品牌名称",remote: "品牌名称已存在"}
				},
				focusCleanup:false,
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			jQuery.validator.addMethod("remarkCheck", function(value,  
	                element, param) { 
				if(value.length>100){
					return false;
				} else{
					return true;
	            }
	        }, $.validator.format("字数超限"));
			// 字符验证
			jQuery.validator.addMethod("stringCheck", function(value, element) {
				return this.optional(element) || /^(?![0-9]+$)[\u4e00-\u9fa5_a-zA-Z0-9_]{2,20}$/.test(value);
			}, "请输入2-20个字符，须含汉字或字母，可带数字");
			$("#remarks").keyup(function(){
				var curLength=$("#remarks").val().length;
				if(curLength>100){
					$("#textLength").css("color","red");
					$("#textLength").text(curLength+"/100");
				}else{
					$("#textLength").css("color","");
					$("#textLength").text(curLength+"/100");
				}
			})
		});
		function changeType(type){
			if('1'==type){
				$('#isMySelfDiv').hide();
			}else{
				$('#isMySelfDiv').show();
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/sys/vender/">制造商品牌列表</a></li>
		<li class="active"><a href="${ctx}/sys/vender/venderAdd?id=${vender.id}">制造商品牌<shiro:hasPermission name="sys:vender:edit">${not empty vender.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:vender:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="vender" action="${ctx}/sys/vender/venderAddSave" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<div style="display:none;">
			<sys:message content="${message}"/>
		</div>
		<div class="control-group">
			<label class="control-label">品牌分类：</label>
			<div class="controls">
				<form:select path="type" class="input-medium" onchange="changeType(this.value)">
					<form:option value="" label="请选择"/>
					<form:options items="${fns:getDictList('vender_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</div>
		</div>
		<div class="control-group hide" id="isMySelfDiv">
			<label class="control-label">是否自主品牌：</label>
			<div class="controls">
				<form:radiobutton path="isMyself" value="1"/>是&emsp;&emsp;&emsp;
				<form:radiobutton path="isMyself" value="0" checked="true"/>否
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">品牌名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">品牌描述：</label>
			<div class="controls" style="position: relative;">
				<span id="textLength" style="bottom:1px;position:absolute;line-height:1;margin-left: 475px;">0/100</span>
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="sys:vender:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>